package com.bigtotoro.shuiyincamera.editimage.task;

import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.os.AsyncTask;
import android.os.Build;

/**
 * Created by panyi on 2016/8/14.
 * <p/>
 * 贴图合成任务 抽象类
 */
public abstract class StickerTask extends AsyncTask<Bitmap, Void, Bitmap> {
//    private Dialog dialog;

    private Activity mContext;

    public StickerTask(Activity activity) {
        this.mContext = activity;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        if (mContext.isFinishing())
            return;

//        dialog = mContext.getLoadingDialog(mContext, R.string.saving_image,
//                false);
//        dialog.show();
    }



    @Override
    protected void onCancelled() {
        super.onCancelled();
//        dialog.dismiss();
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    protected void onCancelled(Bitmap result) {
        super.onCancelled(result);
//        dialog.dismiss();
    }

    @Override
    protected void onPostExecute(Bitmap result) {
        super.onPostExecute(result);
        onPostResult(result);
//        dialog.dismiss();
    }

    public abstract void handleImage(Canvas canvas, Matrix m);
    public abstract void handleImage2(Canvas canvas, Matrix m,int width,int height);

    public abstract void onPostResult(Bitmap result);
}//end class
